You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clean up interrupted JavaScript dependency downloads - #387
An interrupted optional JavaScript dependency download could leave its partial temporary file behind. Give each attempt a unique sibling candidate and remove only that candidate when transfer or publication fails, preserving other attempts and any existing target.
Close streams and disconnect on failure paths. Preserve the original exception and attach cleanup failures as suppressed exceptions. A detected thread interruption before replacement prevents publishing that candidate without clearing the interrupt flag. Successful nonempty transfers retain the existing replacement behavior. This does not add a stale-file purge policy or change dependency selection.
Validation on exact commit c93b5d1: deterministic baseline-failing interrupted-transfer regression; 35 focused JavaScript tests; clean JDK 21 package with 1,730 ordinary tests and two artifact checks, zero failures/errors. Seven new component tests cover interruption, competing attempts, resource failures, empty downloads, replacement failure, cleanup failure and retry. Independent source review approved the exact snapshot and independently passed 52 focused tests, including all seven download tests.
Tests use synthetic in-memory connections and temporary files. No live download, server, script-engine or native runtime acceptance is claimed.
Summary by CodeRabbit
Bug Fixes
Improved reliability of JavaScript dependency downloads. Interrupted, cancelled, failed, or empty transfers no longer leave partial artifacts in place or overwrite a previously available file.
Temporary download files are cleaned up after failures, and existing artifacts remain intact when a replacement cannot be completed. Connections are also closed when downloads finish or fail.
No actionable comments were generated in the recent review.
Walkthrough
downloadArtifact now downloads to a temporary candidate file, checks for empty or interrupted transfers, and moves the completed file into place. It cleans up the candidate after failures. A new test suite covers transfer failures, cleanup, publication, stream closure, and connection disconnection.
Changes: Artifact download
Layer / File(s)
Summary
Download publication and failure handling AdvancedCore/src/main/java/com/bencodez/advancedcore/api/javascript/JavascriptEngineHandler.java, AdvancedCore/src/test/java/com/bencodez/advancedcore/tests/javascript/JavascriptDependencyDownloadTest.java
downloadArtifact stages downloads in a temporary candidate file, rejects empty or interrupted transfers, and moves completed candidates into place. On failure, it attempts candidate cleanup and suppresses cleanup failures on the original exception. Tests cover failure cases, existing-file preservation, successful publication, stream closure, and connection disconnection.
Optional JavaScript dependency downloads now use a unique temporary file per attempt and remove it if the transfer fails or is interrupted. Existing files are preserved and successful downloads still replace them. No actionable merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "Clean up interrupted JavaScript dependency downloads" matches the main change. The PR changes JavascriptEngineHandler.downloadArtifact so each download attempt uses a unique temporary candi…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "Clean up interrupted JavaScript dependency downloads" matches the main change. The PR changes JavascriptEngineHandler.downloadArtifact so each download attempt uses a unique temporary candidate file. On failure, interruption, or empty download, the code deletes only that candidate and attaches cleanup failures as suppressed exceptions. A new JUnit test class covers these cases. The title names the primary behavior and does not list files.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Recent review details
Context from checks skipped due to timeout: 3
GitHub Check: build
GitHub Check: Analyze (java-kotlin)
GitHub Check: Analyze (actions)
Additional context used
Code guidelines: 1
AGENTS.md — auto-discovered
Path-based instructions: 2
Source excerpt: AdvancedCore is a shared Bukkit/Paper/Folia library embedded by plugins such as VotingPlugin, MCPerks, and GraveStonesPlus.
Source excerpt: All test classes and test-only helpers must live under `com.bencodez.advancedcore.tests` or its subpackages, with matching directories under `AdvancedCore/src/test/java`.
Learnt from: CR
Repo: BenCodez/AdvancedCore PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-16T20:27:41.191Z
Learning: Applies to AdvancedCore/src/test/java/** : Source excerpt:
# Maintainer and AI-agent guide
## Build and verification
All test classes and test-only helpers must live under `com.bencodez.advancedcore.tests` or its subpackages, with matching directories under `AdvancedCore/src/test/java`. Keep tests out of production packages. Preserve production visibility when relocating tests; use narrowly scoped test-only reflective helpers when package-private access is required. Preserve test discovery and the package-phase artifact tests.
[warning] 239-239: Avoid user-generated class names for reflection
Context: Class.forName(JavascriptEngineHandler.class.getName() + "$MavenArtifact")
Note: [CWE-470] Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection').
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An interrupted optional JavaScript dependency download could leave its partial temporary file behind. Give each attempt a unique sibling candidate and remove only that candidate when transfer or publication fails, preserving other attempts and any existing target.
Close streams and disconnect on failure paths. Preserve the original exception and attach cleanup failures as suppressed exceptions. A detected thread interruption before replacement prevents publishing that candidate without clearing the interrupt flag. Successful nonempty transfers retain the existing replacement behavior. This does not add a stale-file purge policy or change dependency selection.
Validation on exact commit c93b5d1: deterministic baseline-failing interrupted-transfer regression; 35 focused JavaScript tests; clean JDK 21 package with 1,730 ordinary tests and two artifact checks, zero failures/errors. Seven new component tests cover interruption, competing attempts, resource failures, empty downloads, replacement failure, cleanup failure and retry. Independent source review approved the exact snapshot and independently passed 52 focused tests, including all seven download tests.
Tests use synthetic in-memory connections and temporary files. No live download, server, script-engine or native runtime acceptance is claimed.
Summary by CodeRabbit